<template>
	<view class="page" :style="themeColor">
		<view class="flex flex-direction flex-wrap align-stretch justify-center benben-position-layout flex my_flex_0"
			:style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx'}">
			<view class='flex flex-wrap align-stretch justify-between my_fd0_0'>
				<view class='flex flex-wrap align-center my_fd0_0_c0' @tap.stop="handleJumpDiy" data-type="back" data-url="1">
					<text class='fu-iconfont2  balanceDetail_fd0_0_c0_c0'>&#xE794;</text>
				</view>
				<view class='flex flex-wrap align-center'>
					<text class='my_fd0_0_c1_c0'>签到</text>
				</view>
				<view @tap.stop="handleJumpDiy" data-type="navigateTo" :data-url="'/pages/sousuo/punchinTasks/signAgreements'" class='flex align-center justify-end my_fd0_0_c2' style="transform: translateX(-250rpx);">
					<image class="agreement_icon" :src='STATIC_URL+"501.png"' mode="aspectFill"></image>
				</view>
			</view>
			

		</view>
		<view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
		<view class="loading_css" v-if="isShow">
			<u-loading size="36" color="#F35D2A"></u-loading>
			<view>加载中</view>
		</view>
		<template v-else>
			<view class="sign_bg">
				<image :src='STATIC_URL+"500.png"' mode="aspectFill"></image>
			</view>
			
			<view class="sign_content">
				<view class="learn_money">
					<view class="learn_money_title">我的积分：</view>
					<view class="learn_money_num">{{Number(userInfo.score)}}</view>
				</view>
				<view class="days">
					<view class="days_list">
						<view class="days_list_title">
							<text>已连续签到 </text>
							<text style="font-size: 56rpx;margin-left: 6rpx;font-weight: 500;">{{catch_sign_in_time}}</text>
							<text>天</text>
						 </view>
						<view class="days_list_content">
							<block v-for="(v, k) in ruleList">
								<view :class="v.is_sign == 1 ? 'item4' : 'item3'" :style="k == 6 ? 'marginRight: 0' : ''">
									<image v-if="v.is_sign == 1" class="sign_icon" :src='STATIC_URL+"498.png"' mode="aspectFill"></image>
									<view class="item3_right">
										<image :src='STATIC_URL+"499.png"' mode="aspectFill"></image>
									</view>
									<view class="item3_left">
										<view class="item3_left1" v-if="v.is_sign != 1">第{{v.day}}天</view>
										<view class="item3_left1" v-else style="color: #fff;">第{{v.day}}天</view>
									</view>
									
								</view>
							</block>
						</view>
						
					</view>
				</view>
			</view>
			<view class="sign_btn" v-if="is_today_sign_in == 0" @tap.stop="signSubmit">立即签到</view>
			<view class="sign_bt2" v-else @tap.stop="againSign">已签到</view>
		</template>
		
		
		<!-- <view class="sign_tips">
			<view class="sign_tips_x">
				<view class="sign_tips_title">签到说明</view>
				<view class="sign_tips_content">
					<u-parse :html="content"></u-parse>
				</view>
			</view>
		</view> -->
		<u-mask :show="show" @click="show = false">
			<view class="warp">
				<view class="rect" @tap.stop="">
					<image class="rect_img" :src='STATIC_URL+"500.png"' mode="aspectFill"></image>
					<view class="rect_name1">签到成功</view>
					<view class="rect_name2">获得{{sign_success_num}}积分</view>
					<view class="rect_btn" @tap.stop="show = false">好的</view>
				</view>
			</view>
		</u-mask>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				"content": '1111',
				"userInfo": {
					"user_money": 0
				},
				"catch_sign_in_time": "", //连续签到次数
				"is_catch_sign_in": "", //是否连续签到：0=否，1=是
				"is_today_sign_in": "", //今天是否签到“0=否，1=是
				"sign_success_num": 0,  // 成功的积分
				"ruleList": [], // 规则列表
				"show": false,
				"isShow": true,
			}
		},
		computed: {
			themeColor() {
				return this.$store.getters.themeColor
			},
		},
		onLoad() {
			this.getAgreement();
			this.getSignList();
		},
		onShow() {
			this.getData();
		},
		methods: {
			// 获取签到规则列表  post6551e55df372b
			getSignList() {
				this.$api.post(global.apiUrls.post6551e55df372b, {

				}).then(res => {
					// console.log(res);
					this.isShow = false;
					if (res.data.code == 1) {
						this.catch_sign_in_time = res.data.data.catch_sign_in_time;
						this.is_catch_sign_in = res.data.data.is_catch_sign_in;
						this.is_today_sign_in = res.data.data.is_today_sign_in;
						this.ruleList = res.data.data.data;
					} else {
						this.$message.info(res.data.msg);
					}
				})
			},
			// 点击签到  post6551e8b971c8f
			signSubmit() {
				this.$api.post(global.apiUrls.post6551e8b971c8f, {

				}).then(res => {
					if (res.data.code == 1) {
						this.sign_success_num = res.data.data;
						this.show = true;
						this.getSignList();
						this.getData();
					} else {
						this.$message.info(res.data.msg);
					}
				})
			},
			againSign() {
				this.$message.info('您已签到');
			},
			// 获取会员资料  post5c78c4772da97
			getData() {
				this.$api.post(global.apiUrls.post5c78c4772da97, {

				}).then(res => {
					if (res.data.code == 1) {
						this.userInfo = res.data.data;
					} else {
						this.$message.info(res.data.msg);
					}
				})
			},
			// 协议内容  post63a6ac771882e
			getAgreement() {
				this.$api.post(global.apiUrls.post63a6ac771882e, {
					aid: 3
				}).then(res => {
					if (res.data.code == 1) {
						this.content = res.data.data.content;
					} else {
						this.$message.info(res.data.msg);
					}
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.agreement_icon {
		width: 32rpx;
		height: 32rpx;
		margin-left: 24rpx;
	}
	.sign_bg {
		padding: 140rpx 80rpx 0;
		image {
			width: 591rpx;
			height: 370rpx;
		}
	}

	.warp {
		display: flex;
		align-items: center;
		justify-content: center;
		height: 100%;
	}

	.rect {
		width: 550rpx;
		height: 400rpx;
		background-color: #fff;
		border-radius: 24rpx;
		text-align: center;
		position: relative;
		padding-top: 140rpx;
		.rect_img {
			width: 375rpx;
			height: 236rpx;
			position: absolute;
			top: -110rpx;
			left: 88rpx;
		}
		.rect_name1 {
			font-weight: 500;
			font-size: 32rpx;
			margin-bottom: 18rpx;
			color: #000;
			font-weight: 500;
		}
		.rect_name2 {
			font-size: 28rpx;
			color: #999;
		}
		.rect_btn {
			width: 354rpx;
			height: 80rpx;
			line-height: 80rpx;
			text-align: center;
			background: #F35D2A;
			border-radius: 50rpx;
			font-size: 32rpx;
			color: #fff;
			margin: 40rpx auto 0;
		}
	}
	.sign_content {
		background: #fff;
		border-radius: 24rpx;
		margin: -76rpx 32rpx 0;
	}
	.learn_money {
		padding: 70rpx 40rpx 40rpx;
		display: flex;

		.learn_money_title {
			font-weight: 500;
			font-size: 32rpx;
			color: #333333;
			margin-bottom: 16rpx;
			transform: translateY(20rpx);
		}

		.learn_money_num {
			font-weight: bold;
			font-size: 64rpx;
			color: #FFC558;
		}
	}

	.sign_tips {
		padding: 0 32rpx;

		.sign_tips_x {
			background: #fff;
			padding: 32rpx 32rpx 40rpx;
			border-radius: 24rpx;

			.sign_tips_title {
				font-size: 32rpx;
				font-weight: 500;
				color: #333;
			}

			.sign_tips_content {
				margin-top: 32rpx;
				font-size: 28rpx;
				font-weight: 400;
				color: #666666;
				line-height: 0rpx;
			}
		}
	}
	.sign_btn {
		width: 638rpx;
		height: 88rpx;
		background: linear-gradient(360deg, #FC3045 0%, #FF6E7C 100%);
		border-radius: 44rpx 44rpx 44rpx 44rpx;
		text-align: center;
		line-height: 88rpx;
		color: #fff;
		font-size: 32rpx;
		margin: 88rpx auto 0;
	}
	
	.sign_bt2 {
		width: 638rpx;
		height: 88rpx;
		background: #BFBFBF;
		border-radius: 44rpx 44rpx 44rpx 44rpx;
		text-align: center;
		line-height: 88rpx;
		color: #fff;
		font-size: 32rpx;
		margin: 88rpx auto 0;
	}
	.days {

		margin-bottom: 32rpx;

		.days_list {
			padding: 0rpx 24rpx 40rpx;

			.days_list_title {
				font-weight: 500;
				font-size: 28rpx;
				text-align: center;
				margin-bottom: 40rpx;
				color: #666666;
			}

			
		}

		.days_list_content {
			overflow: hidden;

			.item {
				float: left;
				margin-right: 26rpx;
				width: 136rpx;
				height: 166rpx;
				background: linear-gradient(180deg, #FFA474 0%, #FC3045 100%);
				border-radius: 12rpx 12rpx 12rpx 12rpx;
				text-align: center;
				padding-top: 16rpx;
				color: #fff;
				margin-bottom: 32rpx;

				.item_day {
					font-size: 24rpx;
				}

				.item_img {
					width: 56rpx;
					height: 56rpx;
					margin: 12rpx auto 8rpx;

					image {
						width: 100%;
						height: 100%;
					}
				}

				.item_num {
					font-size: 20rpx;
				}
			}

			.item2 {
				float: left;
				margin-right: 26rpx;
				width: 136rpx;
				height: 166rpx;
				background: #F5F6FA;
				border-radius: 12rpx 12rpx 12rpx 12rpx;
				text-align: center;
				padding-top: 16rpx;
				margin-bottom: 32rpx;

				.item_day {
					font-size: 24rpx;
					color: #333;
				}

				.item_img {
					width: 56rpx;
					height: 56rpx;
					margin: 12rpx auto 8rpx;

					image {
						width: 100%;
						height: 100%;
					}
				}

				.item_num {
					font-size: 20rpx;
					color: #999;
				}
			}

			.item3 {
				float: left;
				width: 84rpx;
				height: 128rpx;
				background: #F5F6FA;
				border-radius: 8rpx;
				text-align: center;
				padding: 24rpx 0rpx 0;
				margin-right: 8rpx;
				text-align: center;
				.sign_icon {
					width: 50rpx;
					height: 50rpx;
					position: absolute;
					left: 0;
					top: 0;
				}
				.item3_left {
					text-align: center;
					.item3_left1 {
						font-size: 24rpx;
						color: #999;
						margin-bottom: 5rpx;
					}

					.item3_left2 {
						font-size: 20rpx;
						color: #999;
					}
				}

				.item3_right {
					width: 44rpx;
					height: 44rpx;
					margin: 0 auto 10rpx;
					image {
						width: 100%;
						height: 100%;
					}
				}
			}

			.item4 {
				float: left;
				width: 84rpx;
				height: 128rpx;
				background: linear-gradient(180deg, #FFAE84 0%, #FC3346 100%);
				border-radius: 8rpx;
				text-align: center;
				padding: 24rpx 0rpx 0;
				margin-right: 8rpx;
				text-align: center;
				position: relative;
				.sign_icon {
					width: 50rpx;
					height: 50rpx;
					position: absolute;
					left: 0;
					top: 0;
				}
				.item3_left {
					text-align: center;
					.item3_left1 {
						font-size: 24rpx;
						color: #999;
						margin-bottom: 5rpx;
					}
				
					.item3_left2 {
						font-size: 20rpx;
						color: #999;
					}
				}
				
				.item3_right {
					width: 44rpx;
					height: 44rpx;
					margin: 0 auto 10rpx;
					image {
						width: 100%;
						height: 100%;
					}
				}
			}

			.item:nth-child(4n+4) {
				margin-right: 0;
			}

			.item2:nth-child(4n+4) {
				margin-right: 0;
			}
		}
	}

	.page {
		width: 100vw;
		overflow-x: hidden;
		min-height: calc(100vh - var(--window-bottom));
		background: url(https://yongzhixing.niurenjianzhan.com/uploads/mini/495.png) no-repeat, rgba(248, 248, 248, 1);
		background-size: 100% auto !important;
	}

	.my_flex_0 {
		background: url(https://yongzhixing.niurenjianzhan.com/uploads/mini/495.png) no-repeat, transparent;
		background-size: 100% !important;
		width: 750rpx;
		height: 88rpx;
		overflow: hidden;
		z-index: 10;
		top: 0rpx;
		background-size: 100% auto !important;
	}

	.balanceDetail_fd0_0_c0_c0 {
		font-size: 32rpx;
		font-weight: 500;
		color: #fff;
	}

	.my_fd0_0_c2_c0 {
		width: 40rpx;
		height: 40rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
	}

	.my_fd0_0_c2 {
		padding: 0rpx 0rpx 0rpx 0rpx;
		width: 150rpx;
	}

	.my_fd0_0_c1_c0 {
		font-size: 36rpx;
		font-weight: 500;
		color: #FFFFFF;
		line-height: 50rpx;
	}

	.my_fd0_0_c0 {
		width: 150rpx;
	}

	.my_fd0_0 {
		padding: 0rpx 32rpx 0rpx 32rpx;
		line-height: 88rpx;
	}

	.my_fd1_1_c3_c1 {
		padding: 16rpx 0rpx 0rpx 0rpx;
		font-size: 24rpx;
		font-weight: 500;
		color: #323232;
	}

	.my_fd1_1_c3_c0 {
		width: 44rpx;
		height: 44rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
	}

	.my_fd1_1_c2_c1 {
		padding: 16rpx 0rpx 0rpx 0rpx;
		font-size: 24rpx;
		font-weight: 500;
		color: #323232;
	}

	.my_fd1_1_c2_c0 {
		width: 44rpx;
		height: 44rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
	}

	.my_fd1_1_c1_c1 {
		padding: 16rpx 0rpx 0rpx 0rpx;
		font-size: 24rpx;
		font-weight: 500;
		color: #323232;
	}

	.my_fd1_1_c1_c0 {
		width: 44rpx;
		height: 44rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
	}

	.my_fd1_1_c0_c1 {
		padding: 16rpx 0rpx 0rpx 0rpx;
		font-size: 24rpx;
		font-weight: 500;
		color: #323232;
	}

	.my_fd1_1_c0_c0 {
		width: 44rpx;
		height: 44rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
	}
</style>
